package com.archgeek.calcite;

import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.impl.AbstractSchema;

import java.util.HashMap;
import java.util.Map;

/**
 * @author pizhihui
 * @date 2024-05-30 22:50
 */
public class InMemorySchema extends AbstractSchema {

    private String name;
    private Map<String, Object> operand;

    public InMemorySchema(String name, Map<String, Object> operand) {
        this.name = name;
        this.operand = operand;
    }

    @Override
    protected Map<String, Table> getTableMap() {
        Map<String, Table> tables = new HashMap<>();

        Storage.getTables().forEach(table -> {
            tables.put(table.getName(), new InMemoryTable(table.getName(), table));
        });

        return tables;
    }
}
